#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;


int maxSum(int num[], int size)
{
    int maxSum = 0;
    int sum = 0;
    
    for (int i = 0; i < size; i++) {
        sum += num[i];
        maxSum = max(maxSum, sum);
        if (sum < 0) sum = 0;
    }
    return maxSum;
}

int main(int argc, char **argv)
{
    int num[] = {1,4,5,6,-5,-10,1,4,5,6,7,-1,2};
    cout << maxSum(num, sizeof(num)/sizeof(int)) << endl;
}
